package user

import (
	"sanguo/cluster"
	"sanguo/node/node_game"
	"time"
)

func ReportNum() {

	//开启一个go程 每隔10秒更新game上的在线人数
	go func() {
		for {
			cluster.PostTask(func() {
				var playerNum int32 = 0
				for _, v := range userMap {
					if v.checkStatus(status_reconnect) || v.checkStatus(status_end) {
						continue
					}
					playerNum++
				}
				node_game.UpdateGamePlayerNum(playerNum)
			})
			time.Sleep(time.Second * 10)
		}
	}()
}

func init() {
	ReportNum()
}
